package org.grc.app.z_project.z_sample.controller;

import org.grc.app.z_project.z_framework.annotation.Action;
import org.grc.app.z_project.z_framework.annotation.Controller;
import org.grc.app.z_project.z_framework.annotation.Inject;
import org.grc.app.z_project.z_framework.bean.Data;
import org.grc.app.z_project.z_framework.bean.Param;
import org.grc.app.z_project.z_framework.bean.View;
import org.grc.app.z_project.z_sample.model.Person;
import org.grc.app.z_project.z_sample.service.Service1;
import org.grc.app.z_project.z_sample.service.Service2;

@Controller
public class Controller1 {

	private Person person = new Person("person1", 11);
	@Inject
	private Service1 service1 = null;
	@Inject
	private Service2 service2 = null;
	
	@Action("get:/index")
	public View index (Param param) {
		return new View("index.jsp");
	}
	
	@Action("get:/helloData")
	public Data helloData (Param param) {
		service1.sayHello();
		service2.sayHello();
		return new Data(person);
	}

	@Action("get:/helloView")
	public View helloView (Param param) {
		return new View("hello.jsp").addModel("person", person);
	}
	
	public void setService1(Service1 service1) {
		this.service1 = service1;
	}
	
	public void setService2(Service2 service2) {
		this.service2 = service2;
	}

	
}
